home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: peer-news.britain.eu.net!info!grace!eegibbon
- From: eegibbon@grace (Matthew Gibbons)
- Subject: Re: Division problem
- X-Nntp-Posting-Host: grace.swan.ac.uk
- Message-ID: <Do3GrH.n27@info.swan.ac.uk>
- Sender: news@info.swan.ac.uk
- Organization: Swansea News Server
- X-Newsreader: TIN [version 1.2 PL2]
- References: <3141571F.41C67EA6@swansea.ac.uk>
- Date: Mon, 11 Mar 1996 08:26:05 GMT
-
- Matthew Gibbons (m.h.gibbons@swansea.ac.uk) wrote:
- : Hi,
-
- : I have a little problem that I can't seem to solve. Any help would be
- : greatly appreciated...
-
- : I have a 64 bit number (grabbed from an external clock source) which
- : I need to be able to divide by a given factor, replacing the original
- : number with the quotient, and returning the remainder.
-
- : The 64 bit number is of this type:
-
- : typedef struct {
- : unsigned char ssr[8];
- : } gtime_t;
-
- : The MSB of this number being ssr[7].
-
- : I want to be able to call a function, say 'divgtime', thus:
-
- : gtime_t gt;
- : unsigned rem;
-
- : :
-
- : // divide the time by 1000
- : rem = divgtime(>, 1000);
-
- : :
-
- : Where 1000 is the desired factor.
-
- : I have tried lots of ways of doing this division, but to no avail.
-
- : Can anyone help me? If you can, please could you email me, as my news
- : link is very slow in updating.
-
- : Thanks in advance,
- : Matthew
-
-
- Peter Kohlberger (acorn@warwick.net) pointed out that I neglected to mention
- the data format of the 64-bit number. Oops.
-
- The number is a 64-bit unsigned integer, which is broken into 8 bytes. The
- number actually represents the time in nanoseconds.
-
- If ssr was { 12, 1, 0, 0, 0, 0, 0, 0 } then the number would represent 278.
-
- I hope this helps.
-
- Cheers,
- Matthew
-
- --
-
- 110000001111111111101110 anyone?
-
-